;;; -*- mode: lisp; coding: utf-8; -*-

(in-package :cl-tmcl)





(defmacro capture-output (&rest body)
  "capture *standard-output* to string"
  `(with-output-to-string (*standard-output*)
     (progn ,@body)))



(defmacro %let-specials (root binding-tuples &rest body)
  `(,root ,binding-tuples
     (declare (special ,@(mapcar #'car binding-tuples)))
     (progn ,@body)))


(defmacro let-specials (binding-tuples &rest body)
  `(%let-specials let ,binding-tuples ,@body))

(defmacro let*-specials (binding-tuples &rest body)
  `(%let-specials let* ,binding-tuples ,@body))



(defmacro introduce-specials (binding-names &rest body)
  `(locally
     (declare (special ,@binding-names))
     (progn ,@body)))




;;;

#|
(let-specials ((a 1) (b 2) (c *standard-output*))
  (print a)
  (print b)
  (print c))
|#


#|
(flet ((print-abc () 
         (introduce-specials (a b c)
           (print a)
           (print b)
           (print c))))
  (let-specials ((a 1) (b 2) (c *standard-output*))
    (print-abc)))
|#



#|
(defun print-abc () 
  (introduce-specials (a b c)
    (print a)
    (print b)
    (print c)))

(defun call-print-abc ()
  (print-abc))


(let-specials ((a 1) (b 2) (c *standard-output*))
  (call-print-abc))
|#

     


;;; EOF